$(function() {
	$('body')
			.append(
					'<div  id="loding" style="position: fixed; left: 430px; top: 185px;display:none;">&nbsp;&nbsp;&nbsp;<img style="width:60px;" src="'
							+ getRootPath()
							+ '/images/loading.gif"><br>加载中，请稍等...</div>');
});
document.write("<script language='javascript' src='" + getRootPath()
		+ "/js/msgbox.js'></script>");
$(document).ajaxStart(function() {
	$('#loding').show();
}).ajaxComplete(
		function(event, xhr, settings) {
			if (xhr.responseText == 'timeout') {
				location.reload();
			}
			try {
				if (eval("(" + xhr.responseText + ")").status == '500'
						|| eval("(" + xhr.responseText + ")").code == '500') {
					var msg = "";
					if (eval("(" + xhr.responseText + ")").data === undefined) {
						msg = eval("(" + xhr.responseText + ")").msg;
					} else {
						msg = eval("(" + xhr.responseText + ")").data;
					}

					$.msgbox.show({
						message : msg,
						icon : 'no',
						beforeHide : function() {
							$('#grayDiv').hide();
						}
					});
					// alert(eval("("+xhr.responseText+")").data);
				}
			} catch (e) {
			}

			$('#loding').hide();
		});

function getRootPath() {
	var curWwwPath = window.document.location.href;
	var pathName = window.document.location.pathname;
	var pos = curWwwPath.indexOf(pathName);
	var localhostPaht = curWwwPath.substring(0, pos);
	var projectName = pathName
			.substring(0, pathName.substr(1).indexOf('/') + 1);
	return (localhostPaht + projectName);
}

function dataFormat(date){
	var year = date.getFullYear();
	var month = (date.getMonth()+1)<10?'0'+(date.getMonth()+1):(date.getMonth()+1);
	var day = date.getDate()<10?'0'+date.getDate():date.getDate();
	var hour = date.getHours()<10?'0'+date.getHours():date.getHours();
	var minute = date.getMinutes()<10?'0'+date.getMinutes():date.getMinutes();
	var second = date.getSeconds()<10?'0'+date.getSeconds():date.getSeconds();
	return year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
}

